< previous page page_337 next page >

Page 337
This control enables you to design complex, grid-like displays that are easier to use than a standard data grid. The reason is that when you create the custom control, you can use any available data-bound control that you need, including ComboBox, CheckBox, and OptionButton.
Building a Database OCX..
Using the techniques you learned in the previous chapter, add a new ActiveX control project to the open project, naming it EmpControl. Then rename the user control ctlEmp. Now add the controls listed in Table 12.5 to the user control.
TABLE 12.5 CONTROLS FOR A DATABASE CUSTOM CONTROL.
ControlPropertyValueMapped Value
TextBoxNametxtEmpNametxtEmpNme
TextBoxNametxtEmpIDtxtEmpNo
TextBoxNametxtBirthDatetxtEmpBDate
LabelNamelblEmpNo
CaptionEmp. No
LabelNamelblBDate
CaptionBirth Date

Because the custom control is going to be repeated for each record in the database, you should try to keep the height of the control as small as possible. The finished control should resemble the one shown in Figure 12.22.
Using the ActiveX Control Interface Wizard, map the Textbox and Checkbox properties to allow the application code to access them at design- and runtime, using the values in Table 12.5. Then, specify that each of the text boxes and the check box on the custom control are data-bound. To set the data-bound properties, open the Procedure Attributes dialog from the Tools menu. Then click the Advanced button at the bottom to display the full dialog form (see Figure 12.23).

 
< previous page page_337 next page >

If you like this book, buy it!